package com.atguigu.gmall.mq.receiver;

import com.rabbitmq.client.Channel;
import lombok.SneakyThrows;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class ConfirmReceiver {

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "queue.confirm",durable = "true",autoDelete = "false"),
            exchange = @Exchange(value = "exchange.confirm",durable = "true",autoDelete = "false"),
            key = {"routing.confirm"}
    ))
    @SneakyThrows
    public void process(String mes, Message message, Channel channel){


        System.out.println("收到的消息：\t"+mes);

        //手动确认
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);

    }


}
